package com.bestdreamer.tcp.demo1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

public class Client {

    public static void main(String[] args)throws IOException{
        Socket socket = new Socket("127.0.0.1",30000);
        // 设置 10秒之后即认为超时
        socket.setSoTimeout(10000);
        // 将 Socket 对应的输入流包装成 BufferedReader
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        // 进行普通 IO 操作
        String line = br.readLine();
        System.out.println("来自服务器的数据："+ line);
        // 关闭输入流，关闭 Socket
        br.close();
        socket.close();
    }

}
